package com.leyou.item.controller;


import com.leyou.item.server.GoodsService;
import com.leyou.item.server.ItemServer;
import com.leyou.pojo.Item;
import com.leyou.pojo.SpuDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class ItemController {
    @Autowired
    private ItemServer itemServer;

@Autowired
private GoodsService goodsService;

    @GetMapping("item")
    public ResponseEntity<Item> saveItem(Item item){
        Item result = itemServer.saveItem(item);
        return ResponseEntity.status(HttpStatus.CREATED).body(result);
    }
    //item/category/of/parent?pid=0
    @PostMapping("goods")
    public ResponseEntity<Void> saveGoods(@RequestBody SpuDTO spuDTO) {
        this.goodsService.save(spuDTO);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
}
